package lzyc.pointsManagement.business.study.service.impl;

import lzyc.pointsManagement.business.study.domain.StudyInfo;
import lzyc.pointsManagement.business.study.mapper.StudyInfoMapper;
import lzyc.pointsManagement.business.study.service.StudyInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (StudyInfo)表服务实现类
 *
 * @author yangyang
 * @since 2024-03-10 17:12:41
 */
@Service("studyInfoService")
public class StudyInfoServiceImpl implements StudyInfoService {
    @Resource
    private StudyInfoMapper studyInfoMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param studyid 主键
     * @return 实例对象
     */
    @Override
    public StudyInfo queryById(String studyid) {
        return this.studyInfoMapper.queryById(studyid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<StudyInfo> queryAllByLimit(int offset, int limit) {
        return this.studyInfoMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param studyInfo 实例对象
     * @return 实例对象
     */
    @Override
    public StudyInfo insert(StudyInfo studyInfo) {
        this.studyInfoMapper.insert(studyInfo);
        return studyInfo;
    }

    /**
     * 修改数据
     *
     * @param studyInfo 实例对象
     * @return 实例对象
     */
    @Override
    public StudyInfo update(StudyInfo studyInfo) {
        this.studyInfoMapper.update(studyInfo);
        return this.queryById(studyInfo.getStudyid());
    }

    /**
     * 通过主键删除数据
     *
     * @param studyid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer studyid) {
        return this.studyInfoMapper.deleteById(studyid) > 0;
    }
}